home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / info / lispref.info-30.z / lispref.info-30
Encoding:
GNU Info File  |  1998-05-21  |  48.9 KB  |  1,172 lines

  1. This is Info file ../../info/lispref.info, produced by Makeinfo version
  2. 1.68 from the input file lispref.texi.
  3.  
  4.    Edition History:
  5.  
  6.    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
  7. Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
  8. Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
  9. XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
  10. GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
  11. Programmer's Manual (for 19.13) Third Edition, July 1995 XEmacs Lisp
  12. Reference Manual (for 19.14 and 20.0) v3.1, March 1996 XEmacs Lisp
  13. Reference Manual (for 19.15 and 20.1, 20.2) v3.2, April, May 1997
  14.  
  15.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
  16. Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
  17. Copyright (C) 1995, 1996 Ben Wing.
  18.  
  19.    Permission is granted to make and distribute verbatim copies of this
  20. manual provided the copyright notice and this permission notice are
  21. preserved on all copies.
  22.  
  23.    Permission is granted to copy and distribute modified versions of
  24. this manual under the conditions for verbatim copying, provided that the
  25. entire resulting derived work is distributed under the terms of a
  26. permission notice identical to this one.
  27.  
  28.    Permission is granted to copy and distribute translations of this
  29. manual into another language, under the above conditions for modified
  30. versions, except that this permission notice may be stated in a
  31. translation approved by the Foundation.
  32.  
  33.    Permission is granted to copy and distribute modified versions of
  34. this manual under the conditions for verbatim copying, provided also
  35. that the section entitled "GNU General Public License" is included
  36. exactly as in the original, and provided that the entire resulting
  37. derived work is distributed under the terms of a permission notice
  38. identical to this one.
  39.  
  40.    Permission is granted to copy and distribute translations of this
  41. manual into another language, under the above conditions for modified
  42. versions, except that the section entitled "GNU General Public License"
  43. may be included in a translation approved by the Free Software
  44. Foundation instead of in the original English.
  45.  
  46. 
  47. File: lispref.info,  Node: Searching and Matching,  Next: Syntax Tables,  Prev: Text,  Up: Top
  48.  
  49. Searching and Matching
  50. **********************
  51.  
  52.    XEmacs provides two ways to search through a buffer for specified
  53. text: exact string searches and regular expression searches.  After a
  54. regular expression search, you can examine the "match data" to
  55. determine which text matched the whole regular expression or various
  56. portions of it.
  57.  
  58. * Menu:
  59.  
  60. * String Search::         Search for an exact match.
  61. * Regular Expressions::   Describing classes of strings.
  62. * Regexp Search::         Searching for a match for a regexp.
  63. * POSIX Regexps::         Searching POSIX-style for the longest match.
  64. * Search and Replace::      Internals of `query-replace'.
  65. * Match Data::            Finding out which part of the text matched
  66.                             various parts of a regexp, after regexp search.
  67. * Searching and Case::    Case-independent or case-significant searching.
  68. * Standard Regexps::      Useful regexps for finding sentences, pages,...
  69.  
  70.    The `skip-chars...' functions also perform a kind of searching.
  71. *Note Skipping Characters::.
  72.  
  73. 
  74. File: lispref.info,  Node: String Search,  Next: Regular Expressions,  Up: Searching and Matching
  75.  
  76. Searching for Strings
  77. =====================
  78.  
  79.    These are the primitive functions for searching through the text in a
  80. buffer.  They are meant for use in programs, but you may call them
  81. interactively.  If you do so, they prompt for the search string; LIMIT
  82. and NOERROR are set to `nil', and REPEAT is set to 1.
  83.  
  84.  - Command: search-forward STRING &optional LIMIT NOERROR REPEAT
  85.      This function searches forward from point for an exact match for
  86.      STRING.  If successful, it sets point to the end of the occurrence
  87.      found, and returns the new value of point.  If no match is found,
  88.      the value and side effects depend on NOERROR (see below).
  89.  
  90.      In the following example, point is initially at the beginning of
  91.      the line.  Then `(search-forward "fox")' moves point after the last
  92.      letter of `fox':
  93.  
  94.           ---------- Buffer: foo ----------
  95.           -!-The quick brown fox jumped over the lazy dog.
  96.           ---------- Buffer: foo ----------
  97.           
  98.           (search-forward "fox")
  99.                => 20
  100.           
  101.           ---------- Buffer: foo ----------
  102.           The quick brown fox-!- jumped over the lazy dog.
  103.           ---------- Buffer: foo ----------
  104.  
  105.      The argument LIMIT specifies the upper bound to the search.  (It
  106.      must be a position in the current buffer.)  No match extending
  107.      after that position is accepted.  If LIMIT is omitted or `nil', it
  108.      defaults to the end of the accessible portion of the buffer.
  109.  
  110.      What happens when the search fails depends on the value of
  111.      NOERROR.  If NOERROR is `nil', a `search-failed' error is
  112.      signaled.  If NOERROR is `t', `search-forward' returns `nil' and
  113.      does nothing.  If NOERROR is neither `nil' nor `t', then
  114.      `search-forward' moves point to the upper bound and returns `nil'.
  115.      (It would be more consistent now to return the new position of
  116.      point in that case, but some programs may depend on a value of
  117.      `nil'.)
  118.  
  119.      If REPEAT is supplied (it must be a positive number), then the
  120.      search is repeated that many times (each time starting at the end
  121.      of the previous time's match).  If these successive searches
  122.      succeed, the function succeeds, moving point and returning its new
  123.      value.  Otherwise the search fails.
  124.  
  125.  - Command: search-backward STRING &optional LIMIT NOERROR REPEAT
  126.      This function searches backward from point for STRING.  It is just
  127.      like `search-forward' except that it searches backwards and leaves
  128.      point at the beginning of the match.
  129.  
  130.  - Command: word-search-forward STRING &optional LIMIT NOERROR REPEAT
  131.      This function searches forward from point for a "word" match for
  132.      STRING.  If it finds a match, it sets point to the end of the
  133.      match found, and returns the new value of point.
  134.  
  135.      Word matching regards STRING as a sequence of words, disregarding
  136.      punctuation that separates them.  It searches the buffer for the
  137.      same sequence of words.  Each word must be distinct in the buffer
  138.      (searching for the word `ball' does not match the word `balls'),
  139.      but the details of punctuation and spacing are ignored (searching
  140.      for `ball boy' does match `ball.  Boy!').
  141.  
  142.      In this example, point is initially at the beginning of the
  143.      buffer; the search leaves it between the `y' and the `!'.
  144.  
  145.           ---------- Buffer: foo ----------
  146.           -!-He said "Please!  Find
  147.           the ball boy!"
  148.           ---------- Buffer: foo ----------
  149.           
  150.           (word-search-forward "Please find the ball, boy.")
  151.                => 35
  152.           
  153.           ---------- Buffer: foo ----------
  154.           He said "Please!  Find
  155.           the ball boy-!-!"
  156.           ---------- Buffer: foo ----------
  157.  
  158.      If LIMIT is non-`nil' (it must be a position in the current
  159.      buffer), then it is the upper bound to the search.  The match
  160.      found must not extend after that position.
  161.  
  162.      If NOERROR is `nil', then `word-search-forward' signals an error
  163.      if the search fails.  If NOERROR is `t', then it returns `nil'
  164.      instead of signaling an error.  If NOERROR is neither `nil' nor
  165.      `t', it moves point to LIMIT (or the end of the buffer) and
  166.      returns `nil'.
  167.  
  168.      If REPEAT is non-`nil', then the search is repeated that many
  169.      times.  Point is positioned at the end of the last match.
  170.  
  171.  - Command: word-search-backward STRING &optional LIMIT NOERROR REPEAT
  172.      This function searches backward from point for a word match to
  173.      STRING.  This function is just like `word-search-forward' except
  174.      that it searches backward and normally leaves point at the
  175.      beginning of the match.
  176.  
  177. 
  178. File: lispref.info,  Node: Regular Expressions,  Next: Regexp Search,  Prev: String Search,  Up: Searching and Matching
  179.  
  180. Regular Expressions
  181. ===================
  182.  
  183.    A "regular expression" ("regexp", for short) is a pattern that
  184. denotes a (possibly infinite) set of strings.  Searching for matches for
  185. a regexp is a very powerful operation.  This section explains how to
  186. write regexps; the following section says how to search for them.
  187.  
  188. * Menu:
  189.  
  190. * Syntax of Regexps::       Rules for writing regular expressions.
  191. * Regexp Example::          Illustrates regular expression syntax.
  192.  
  193. 
  194. File: lispref.info,  Node: Syntax of Regexps,  Next: Regexp Example,  Up: Regular Expressions
  195.  
  196. Syntax of Regular Expressions
  197. -----------------------------
  198.  
  199.    Regular expressions have a syntax in which a few characters are
  200. special constructs and the rest are "ordinary".  An ordinary character
  201. is a simple regular expression that matches that character and nothing
  202. else.  The special characters are `.', `*', `+', `?', `[', `]', `^',
  203. `$', and `\'; no new special characters will be defined in the future.
  204. Any other character appearing in a regular expression is ordinary,
  205. unless a `\' precedes it.
  206.  
  207.    For example, `f' is not a special character, so it is ordinary, and
  208. therefore `f' is a regular expression that matches the string `f' and
  209. no other string.  (It does *not* match the string `ff'.)  Likewise, `o'
  210. is a regular expression that matches only `o'.
  211.  
  212.    Any two regular expressions A and B can be concatenated.  The result
  213. is a regular expression that matches a string if A matches some amount
  214. of the beginning of that string and B matches the rest of the string.
  215.  
  216.    As a simple example, we can concatenate the regular expressions `f'
  217. and `o' to get the regular expression `fo', which matches only the
  218. string `fo'.  Still trivial.  To do something more powerful, you need
  219. to use one of the special characters.  Here is a list of them:
  220.  
  221. `. (Period)'
  222.      is a special character that matches any single character except a
  223.      newline.  Using concatenation, we can make regular expressions
  224.      like `a.b', which matches any three-character string that begins
  225.      with `a' and ends with `b'.
  226.  
  227. `*'
  228.      is not a construct by itself; it is a suffix operator that means to
  229.      repeat the preceding regular expression as many times as possible.
  230.      In `fo*', the `*' applies to the `o', so `fo*' matches one `f'
  231.      followed by any number of `o's.  The case of zero `o's is allowed:
  232.      `fo*' does match `f'.
  233.  
  234.      `*' always applies to the *smallest* possible preceding
  235.      expression.  Thus, `fo*' has a repeating `o', not a repeating `fo'.
  236.  
  237.      The matcher processes a `*' construct by matching, immediately, as
  238.      many repetitions as can be found.  Then it continues with the rest
  239.      of the pattern.  If that fails, backtracking occurs, discarding
  240.      some of the matches of the `*'-modified construct in case that
  241.      makes it possible to match the rest of the pattern.  For example,
  242.      in matching `ca*ar' against the string `caaar', the `a*' first
  243.      tries to match all three `a's; but the rest of the pattern is `ar'
  244.      and there is only `r' left to match, so this try fails.  The next
  245.      alternative is for `a*' to match only two `a's.  With this choice,
  246.      the rest of the regexp matches successfully.
  247.  
  248.      Nested repetition operators can be extremely slow if they specify
  249.      backtracking loops.  For example, it could take hours for the
  250.      regular expression `\(x+y*\)*a' to match the sequence
  251.      `xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz'.  The slowness is because
  252.      Emacs must try each imaginable way of grouping the 35 `x''s before
  253.      concluding that none of them can work.  To make sure your regular
  254.      expressions run fast, check nested repetitions carefully.
  255.  
  256. `+'
  257.      is a suffix operator similar to `*' except that the preceding
  258.      expression must match at least once.  So, for example, `ca+r'
  259.      matches the strings `car' and `caaaar' but not the string `cr',
  260.      whereas `ca*r' matches all three strings.
  261.  
  262. `?'
  263.      is a suffix operator similar to `*' except that the preceding
  264.      expression can match either once or not at all.  For example,
  265.      `ca?r' matches `car' or `cr', but does not match anyhing else.
  266.  
  267. `[ ... ]'
  268.      `[' begins a "character set", which is terminated by a `]'.  In
  269.      the simplest case, the characters between the two brackets form
  270.      the set.  Thus, `[ad]' matches either one `a' or one `d', and
  271.      `[ad]*' matches any string composed of just `a's and `d's
  272.      (including the empty string), from which it follows that `c[ad]*r'
  273.      matches `cr', `car', `cdr', `caddaar', etc.
  274.  
  275.      The usual regular expression special characters are not special
  276.      inside a character set.  A completely different set of special
  277.      characters exists inside character sets: `]', `-' and `^'.
  278.  
  279.      `-' is used for ranges of characters.  To write a range, write two
  280.      characters with a `-' between them.  Thus, `[a-z]' matches any
  281.      lower case letter.  Ranges may be intermixed freely with individual
  282.      characters, as in `[a-z$%.]', which matches any lower case letter
  283.      or `$', `%', or a period.
  284.  
  285.      To include a `]' in a character set, make it the first character.
  286.      For example, `[]a]' matches `]' or `a'.  To include a `-', write
  287.      `-' as the first character in the set, or put it immediately after
  288.      a range.  (You can replace one individual character C with the
  289.      range `C-C' to make a place to put the `-'.)  There is no way to
  290.      write a set containing just `-' and `]'.
  291.  
  292.      To include `^' in a set, put it anywhere but at the beginning of
  293.      the set.
  294.  
  295. `[^ ... ]'
  296.      `[^' begins a "complement character set", which matches any
  297.      character except the ones specified.  Thus, `[^a-z0-9A-Z]' matches
  298.      all characters *except* letters and digits.
  299.  
  300.      `^' is not special in a character set unless it is the first
  301.      character.  The character following the `^' is treated as if it
  302.      were first (thus, `-' and `]' are not special there).
  303.  
  304.      Note that a complement character set can match a newline, unless
  305.      newline is mentioned as one of the characters not to match.
  306.  
  307. `^'
  308.      is a special character that matches the empty string, but only at
  309.      the beginning of a line in the text being matched.  Otherwise it
  310.      fails to match anything.  Thus, `^foo' matches a `foo' that occurs
  311.      at the beginning of a line.
  312.  
  313.      When matching a string instead of a buffer, `^' matches at the
  314.      beginning of the string or after a newline character `\n'.
  315.  
  316. `$'
  317.      is similar to `^' but matches only at the end of a line.  Thus,
  318.      `x+$' matches a string of one `x' or more at the end of a line.
  319.  
  320.      When matching a string instead of a buffer, `$' matches at the end
  321.      of the string or before a newline character `\n'.
  322.  
  323. `\'
  324.      has two functions: it quotes the special characters (including
  325.      `\'), and it introduces additional special constructs.
  326.  
  327.      Because `\' quotes special characters, `\$' is a regular
  328.      expression that matches only `$', and `\[' is a regular expression
  329.      that matches only `[', and so on.
  330.  
  331.      Note that `\' also has special meaning in the read syntax of Lisp
  332.      strings (*note String Type::.), and must be quoted with `\'.  For
  333.      example, the regular expression that matches the `\' character is
  334.      `\\'.  To write a Lisp string that contains the characters `\\',
  335.      Lisp syntax requires you to quote each `\' with another `\'.
  336.      Therefore, the read syntax for a regular expression matching `\'
  337.      is `"\\\\"'.
  338.  
  339.    *Please note:* For historical compatibility, special characters are
  340. treated as ordinary ones if they are in contexts where their special
  341. meanings make no sense.  For example, `*foo' treats `*' as ordinary
  342. since there is no preceding expression on which the `*' can act.  It is
  343. poor practice to depend on this behavior; quote the special character
  344. anyway, regardless of where it appears.
  345.  
  346.    For the most part, `\' followed by any character matches only that
  347. character.  However, there are several exceptions: characters that,
  348. when preceded by `\', are special constructs.  Such characters are
  349. always ordinary when encountered on their own.  Here is a table of `\'
  350. constructs:
  351.  
  352. `\|'
  353.      specifies an alternative.  Two regular expressions A and B with
  354.      `\|' in between form an expression that matches anything that
  355.      either A or B matches.
  356.  
  357.      Thus, `foo\|bar' matches either `foo' or `bar' but no other string.
  358.  
  359.      `\|' applies to the largest possible surrounding expressions.
  360.      Only a surrounding `\( ... \)' grouping can limit the grouping
  361.      power of `\|'.
  362.  
  363.      Full backtracking capability exists to handle multiple uses of
  364.      `\|'.
  365.  
  366. `\( ... \)'
  367.      is a grouping construct that serves three purposes:
  368.  
  369.        1. To enclose a set of `\|' alternatives for other operations.
  370.           Thus, `\(foo\|bar\)x' matches either `foox' or `barx'.
  371.  
  372.        2. To enclose an expression for a suffix operator such as `*' to
  373.           act on.  Thus, `ba\(na\)*' matches `bananana', etc., with any
  374.           (zero or more) number of `na' strings.
  375.  
  376.        3. To record a matched substring for future reference.
  377.  
  378.      This last application is not a consequence of the idea of a
  379.      parenthetical grouping; it is a separate feature that happens to be
  380.      assigned as a second meaning to the same `\( ... \)' construct
  381.      because there is no conflict in practice between the two meanings.
  382.      Here is an explanation of this feature:
  383.  
  384. `\DIGIT'
  385.      matches the same text that matched the DIGITth occurrence of a `\(
  386.      ... \)' construct.
  387.  
  388.      In other words, after the end of a `\( ... \)' construct.  the
  389.      matcher remembers the beginning and end of the text matched by that
  390.      construct.  Then, later on in the regular expression, you can use
  391.      `\' followed by DIGIT to match that same text, whatever it may
  392.      have been.
  393.  
  394.      The strings matching the first nine `\( ... \)' constructs
  395.      appearing in a regular expression are assigned numbers 1 through 9
  396.      in the order that the open parentheses appear in the regular
  397.      expression.  So you can use `\1' through `\9' to refer to the text
  398.      matched by the corresponding `\( ... \)' constructs.
  399.  
  400.      For example, `\(.*\)\1' matches any newline-free string that is
  401.      composed of two identical halves.  The `\(.*\)' matches the first
  402.      half, which may be anything, but the `\1' that follows must match
  403.      the same exact text.
  404.  
  405. `\w'
  406.      matches any word-constituent character.  The editor syntax table
  407.      determines which characters these are.  *Note Syntax Tables::.
  408.  
  409. `\W'
  410.      matches any character that is not a word constituent.
  411.  
  412. `\sCODE'
  413.      matches any character whose syntax is CODE.  Here CODE is a
  414.      character that represents a syntax code: thus, `w' for word
  415.      constituent, `-' for whitespace, `(' for open parenthesis, etc.
  416.      *Note Syntax Tables::, for a list of syntax codes and the
  417.      characters that stand for them.
  418.  
  419. `\SCODE'
  420.      matches any character whose syntax is not CODE.
  421.  
  422.    The following regular expression constructs match the empty
  423. string--that is, they don't use up any characters--but whether they
  424. match depends on the context.
  425.  
  426. `\`'
  427.      matches the empty string, but only at the beginning of the buffer
  428.      or string being matched against.
  429.  
  430. `\''
  431.      matches the empty string, but only at the end of the buffer or
  432.      string being matched against.
  433.  
  434. `\='
  435.      matches the empty string, but only at point.  (This construct is
  436.      not defined when matching against a string.)
  437.  
  438. `\b'
  439.      matches the empty string, but only at the beginning or end of a
  440.      word.  Thus, `\bfoo\b' matches any occurrence of `foo' as a
  441.      separate word.  `\bballs?\b' matches `ball' or `balls' as a
  442.      separate word.
  443.  
  444. `\B'
  445.      matches the empty string, but *not* at the beginning or end of a
  446.      word.
  447.  
  448. `\<'
  449.      matches the empty string, but only at the beginning of a word.
  450.  
  451. `\>'
  452.      matches the empty string, but only at the end of a word.
  453.  
  454.    Not every string is a valid regular expression.  For example, a
  455. string with unbalanced square brackets is invalid (with a few
  456. exceptions, such as `[]]'), and so is a string that ends with a single
  457. `\'.  If an invalid regular expression is passed to any of the search
  458. functions, an `invalid-regexp' error is signaled.
  459.  
  460.  - Function: regexp-quote STRING
  461.      This function returns a regular expression string that matches
  462.      exactly STRING and nothing else.  This allows you to request an
  463.      exact string match when calling a function that wants a regular
  464.      expression.
  465.  
  466.           (regexp-quote "^The cat$")
  467.                => "\\^The cat\\$"
  468.  
  469.      One use of `regexp-quote' is to combine an exact string match with
  470.      context described as a regular expression.  For example, this
  471.      searches for the string that is the value of `string', surrounded
  472.      by whitespace:
  473.  
  474.           (re-search-forward
  475.            (concat "\\s-" (regexp-quote string) "\\s-"))
  476.  
  477. 
  478. File: lispref.info,  Node: Regexp Example,  Prev: Syntax of Regexps,  Up: Regular Expressions
  479.  
  480. Complex Regexp Example
  481. ----------------------
  482.  
  483.    Here is a complicated regexp, used by XEmacs to recognize the end of
  484. a sentence together with any whitespace that follows.  It is the value
  485. of the variable `sentence-end'.
  486.  
  487.    First, we show the regexp as a string in Lisp syntax to distinguish
  488. spaces from tab characters.  The string constant begins and ends with a
  489. double-quote.  `\"' stands for a double-quote as part of the string,
  490. `\\' for a backslash as part of the string, `\t' for a tab and `\n' for
  491. a newline.
  492.  
  493.      "[.?!][]\"')}]*\\($\\| $\\|\t\\|  \\)[ \t\n]*"
  494.  
  495.    In contrast, if you evaluate the variable `sentence-end', you will
  496. see the following:
  497.  
  498.      sentence-end
  499.      =>
  500.      "[.?!][]\"')}]*\\($\\| $\\|  \\|  \\)[
  501.      ]*"
  502.  
  503. In this output, tab and newline appear as themselves.
  504.  
  505.    This regular expression contains four parts in succession and can be
  506. deciphered as follows:
  507.  
  508. `[.?!]'
  509.      The first part of the pattern is a character set that matches any
  510.      one of three characters: period, question mark, and exclamation
  511.      mark.  The match must begin with one of these three characters.
  512.  
  513. `[]\"')}]*'
  514.      The second part of the pattern matches any closing braces and
  515.      quotation marks, zero or more of them, that may follow the period,
  516.      question mark or exclamation mark.  The `\"' is Lisp syntax for a
  517.      double-quote in a string.  The `*' at the end indicates that the
  518.      immediately preceding regular expression (a character set, in this
  519.      case) may be repeated zero or more times.
  520.  
  521. `\\($\\| $\\|\t\\|  \\)'
  522.      The third part of the pattern matches the whitespace that follows
  523.      the end of a sentence: the end of a line, or a tab, or two spaces.
  524.      The double backslashes mark the parentheses and vertical bars as
  525.      regular expression syntax; the parentheses delimit a group and the
  526.      vertical bars separate alternatives.  The dollar sign is used to
  527.      match the end of a line.
  528.  
  529. `[ \t\n]*'
  530.      Finally, the last part of the pattern matches any additional
  531.      whitespace beyond the minimum needed to end a sentence.
  532.  
  533. 
  534. File: lispref.info,  Node: Regexp Search,  Next: POSIX Regexps,  Prev: Regular Expressions,  Up: Searching and Matching
  535.  
  536. Regular Expression Searching
  537. ============================
  538.  
  539.    In XEmacs, you can search for the next match for a regexp either
  540. incrementally or not.  Incremental search commands are described in the
  541. `The XEmacs Reference Manual'.  *Note Regular Expression Search:
  542. (emacs)Regexp Search.  Here we describe only the search functions
  543. useful in programs.  The principal one is `re-search-forward'.
  544.  
  545.  - Command: re-search-forward REGEXP &optional LIMIT NOERROR REPEAT
  546.      This function searches forward in the current buffer for a string
  547.      of text that is matched by the regular expression REGEXP.  The
  548.      function skips over any amount of text that is not matched by
  549.      REGEXP, and leaves point at the end of the first match found.  It
  550.      returns the new value of point.
  551.  
  552.      If LIMIT is non-`nil' (it must be a position in the current
  553.      buffer), then it is the upper bound to the search.  No match
  554.      extending after that position is accepted.
  555.  
  556.      What happens when the search fails depends on the value of
  557.      NOERROR.  If NOERROR is `nil', a `search-failed' error is
  558.      signaled.  If NOERROR is `t', `re-search-forward' does nothing and
  559.      returns `nil'.  If NOERROR is neither `nil' nor `t', then
  560.      `re-search-forward' moves point to LIMIT (or the end of the
  561.      buffer) and returns `nil'.
  562.  
  563.      If REPEAT is supplied (it must be a positive number), then the
  564.      search is repeated that many times (each time starting at the end
  565.      of the previous time's match).  If these successive searches
  566.      succeed, the function succeeds, moving point and returning its new
  567.      value.  Otherwise the search fails.
  568.  
  569.      In the following example, point is initially before the `T'.
  570.      Evaluating the search call moves point to the end of that line
  571.      (between the `t' of `hat' and the newline).
  572.  
  573.           ---------- Buffer: foo ----------
  574.           I read "-!-The cat in the hat
  575.           comes back" twice.
  576.           ---------- Buffer: foo ----------
  577.           
  578.           (re-search-forward "[a-z]+" nil t 5)
  579.                => 27
  580.           
  581.           ---------- Buffer: foo ----------
  582.           I read "The cat in the hat-!-
  583.           comes back" twice.
  584.           ---------- Buffer: foo ----------
  585.  
  586.  - Command: re-search-backward REGEXP &optional LIMIT NOERROR REPEAT
  587.      This function searches backward in the current buffer for a string
  588.      of text that is matched by the regular expression REGEXP, leaving
  589.      point at the beginning of the first text found.
  590.  
  591.      This function is analogous to `re-search-forward', but they are not
  592.      simple mirror images.  `re-search-forward' finds the match whose
  593.      beginning is as close as possible to the starting point.  If
  594.      `re-search-backward' were a perfect mirror image, it would find the
  595.      match whose end is as close as possible.  However, in fact it
  596.      finds the match whose beginning is as close as possible.  The
  597.      reason is that matching a regular expression at a given spot
  598.      always works from beginning to end, and starts at a specified
  599.      beginning position.
  600.  
  601.      A true mirror-image of `re-search-forward' would require a special
  602.      feature for matching regexps from end to beginning.  It's not
  603.      worth the trouble of implementing that.
  604.  
  605.  - Function: string-match REGEXP STRING &optional START
  606.      This function returns the index of the start of the first match for
  607.      the regular expression REGEXP in STRING, or `nil' if there is no
  608.      match.  If START is non-`nil', the search starts at that index in
  609.      STRING.
  610.  
  611.      For example,
  612.  
  613.           (string-match
  614.            "quick" "The quick brown fox jumped quickly.")
  615.                => 4
  616.           (string-match
  617.            "quick" "The quick brown fox jumped quickly." 8)
  618.                => 27
  619.  
  620.      The index of the first character of the string is 0, the index of
  621.      the second character is 1, and so on.
  622.  
  623.      After this function returns, the index of the first character
  624.      beyond the match is available as `(match-end 0)'.  *Note Match
  625.      Data::.
  626.  
  627.           (string-match
  628.            "quick" "The quick brown fox jumped quickly." 8)
  629.                => 27
  630.           
  631.           (match-end 0)
  632.                => 32
  633.  
  634.  - Function: looking-at REGEXP
  635.      This function determines whether the text in the current buffer
  636.      directly following point matches the regular expression REGEXP.
  637.      "Directly following" means precisely that: the search is
  638.      "anchored" and it can succeed only starting with the first
  639.      character following point.  The result is `t' if so, `nil'
  640.      otherwise.
  641.  
  642.      This function does not move point, but it updates the match data,
  643.      which you can access using `match-beginning' and `match-end'.
  644.      *Note Match Data::.
  645.  
  646.      In this example, point is located directly before the `T'.  If it
  647.      were anywhere else, the result would be `nil'.
  648.  
  649.           ---------- Buffer: foo ----------
  650.           I read "-!-The cat in the hat
  651.           comes back" twice.
  652.           ---------- Buffer: foo ----------
  653.           
  654.           (looking-at "The cat in the hat$")
  655.                => t
  656.  
  657. 
  658. File: lispref.info,  Node: POSIX Regexps,  Next: Search and Replace,  Prev: Regexp Search,  Up: Searching and Matching
  659.  
  660. POSIX Regular Expression Searching
  661. ==================================
  662.  
  663.    The usual regular expression functions do backtracking when necessary
  664. to handle the `\|' and repetition constructs, but they continue this
  665. only until they find *some* match.  Then they succeed and report the
  666. first match found.
  667.  
  668.    This section describes alternative search functions which perform the
  669. full backtracking specified by the POSIX standard for regular expression
  670. matching.  They continue backtracking until they have tried all
  671. possibilities and found all matches, so they can report the longest
  672. match, as required by POSIX.  This is much slower, so use these
  673. functions only when you really need the longest match.
  674.  
  675.    In Emacs versions prior to 19.29, these functions did not exist, and
  676. the functions described above implemented full POSIX backtracking.
  677.  
  678.  - Function: posix-search-forward REGEXP &optional LIMIT NOERROR REPEAT
  679.      This is like `re-search-forward' except that it performs the full
  680.      backtracking specified by the POSIX standard for regular expression
  681.      matching.
  682.  
  683.  - Function: posix-search-backward REGEXP &optional LIMIT NOERROR REPEAT
  684.      This is like `re-search-backward' except that it performs the full
  685.      backtracking specified by the POSIX standard for regular expression
  686.      matching.
  687.  
  688.  - Function: posix-looking-at REGEXP
  689.      This is like `looking-at' except that it performs the full
  690.      backtracking specified by the POSIX standard for regular expression
  691.      matching.
  692.  
  693.  - Function: posix-string-match REGEXP STRING &optional START
  694.      This is like `string-match' except that it performs the full
  695.      backtracking specified by the POSIX standard for regular expression
  696.      matching.
  697.  
  698. 
  699. File: lispref.info,  Node: Search and Replace,  Next: Match Data,  Prev: POSIX Regexps,  Up: Searching and Matching
  700.  
  701. Search and Replace
  702. ==================
  703.  
  704.  - Function: perform-replace FROM-STRING REPLACEMENTS QUERY-FLAG
  705.           REGEXP-FLAG DELIMITED-FLAG &optional REPEAT-COUNT MAP
  706.      This function is the guts of `query-replace' and related commands.
  707.      It searches for occurrences of FROM-STRING and replaces some or
  708.      all of them.  If QUERY-FLAG is `nil', it replaces all occurrences;
  709.      otherwise, it asks the user what to do about each one.
  710.  
  711.      If REGEXP-FLAG is non-`nil', then FROM-STRING is considered a
  712.      regular expression; otherwise, it must match literally.  If
  713.      DELIMITED-FLAG is non-`nil', then only replacements surrounded by
  714.      word boundaries are considered.
  715.  
  716.      The argument REPLACEMENTS specifies what to replace occurrences
  717.      with.  If it is a string, that string is used.  It can also be a
  718.      list of strings, to be used in cyclic order.
  719.  
  720.      If REPEAT-COUNT is non-`nil', it should be an integer.  Then it
  721.      specifies how many times to use each of the strings in the
  722.      REPLACEMENTS list before advancing cyclicly to the next one.
  723.  
  724.      Normally, the keymap `query-replace-map' defines the possible user
  725.      responses for queries.  The argument MAP, if non-`nil', is a
  726.      keymap to use instead of `query-replace-map'.
  727.  
  728.  - Variable: query-replace-map
  729.      This variable holds a special keymap that defines the valid user
  730.      responses for `query-replace' and related functions, as well as
  731.      `y-or-n-p' and `map-y-or-n-p'.  It is unusual in two ways:
  732.  
  733.         * The "key bindings" are not commands, just symbols that are
  734.           meaningful to the functions that use this map.
  735.  
  736.         * Prefix keys are not supported; each key binding must be for a
  737.           single event key sequence.  This is because the functions
  738.           don't use read key sequence to get the input; instead, they
  739.           read a single event and look it up "by hand."
  740.  
  741.    Here are the meaningful "bindings" for `query-replace-map'.  Several
  742. of them are meaningful only for `query-replace' and friends.
  743.  
  744. `act'
  745.      Do take the action being considered--in other words, "yes."
  746.  
  747. `skip'
  748.      Do not take action for this question--in other words, "no."
  749.  
  750. `exit'
  751.      Answer this question "no," and give up on the entire series of
  752.      questions, assuming that the answers will be "no."
  753.  
  754. `act-and-exit'
  755.      Answer this question "yes," and give up on the entire series of
  756.      questions, assuming that subsequent answers will be "no."
  757.  
  758. `act-and-show'
  759.      Answer this question "yes," but show the results--don't advance yet
  760.      to the next question.
  761.  
  762. `automatic'
  763.      Answer this question and all subsequent questions in the series
  764.      with "yes," without further user interaction.
  765.  
  766. `backup'
  767.      Move back to the previous place that a question was asked about.
  768.  
  769. `edit'
  770.      Enter a recursive edit to deal with this question--instead of any
  771.      other action that would normally be taken.
  772.  
  773. `delete-and-edit'
  774.      Delete the text being considered, then enter a recursive edit to
  775.      replace it.
  776.  
  777. `recenter'
  778.      Redisplay and center the window, then ask the same question again.
  779.  
  780. `quit'
  781.      Perform a quit right away.  Only `y-or-n-p' and related functions
  782.      use this answer.
  783.  
  784. `help'
  785.      Display some help, then ask again.
  786.  
  787. 
  788. File: lispref.info,  Node: Match Data,  Next: Searching and Case,  Prev: Search and Replace,  Up: Searching and Matching
  789.  
  790. The Match Data
  791. ==============
  792.  
  793.    XEmacs keeps track of the positions of the start and end of segments
  794. of text found during a regular expression search.  This means, for
  795. example, that you can search for a complex pattern, such as a date in
  796. an Rmail message, and then extract parts of the match under control of
  797. the pattern.
  798.  
  799.    Because the match data normally describe the most recent search only,
  800. you must be careful not to do another search inadvertently between the
  801. search you wish to refer back to and the use of the match data.  If you
  802. can't avoid another intervening search, you must save and restore the
  803. match data around it, to prevent it from being overwritten.
  804.  
  805. * Menu:
  806.  
  807. * Simple Match Data::     Accessing single items of match data,
  808.                 such as where a particular subexpression started.
  809. * Replacing Match::      Replacing a substring that was matched.
  810. * Entire Match Data::     Accessing the entire match data at once, as a list.
  811. * Saving Match Data::     Saving and restoring the match data.
  812.  
  813. 
  814. File: lispref.info,  Node: Simple Match Data,  Next: Replacing Match,  Up: Match Data
  815.  
  816. Simple Match Data Access
  817. ------------------------
  818.  
  819.    This section explains how to use the match data to find out what was
  820. matched by the last search or match operation.
  821.  
  822.    You can ask about the entire matching text, or about a particular
  823. parenthetical subexpression of a regular expression.  The COUNT
  824. argument in the functions below specifies which.  If COUNT is zero, you
  825. are asking about the entire match.  If COUNT is positive, it specifies
  826. which subexpression you want.
  827.  
  828.    Recall that the subexpressions of a regular expression are those
  829. expressions grouped with escaped parentheses, `\(...\)'.  The COUNTth
  830. subexpression is found by counting occurrences of `\(' from the
  831. beginning of the whole regular expression.  The first subexpression is
  832. numbered 1, the second 2, and so on.  Only regular expressions can have
  833. subexpressions--after a simple string search, the only information
  834. available is about the entire match.
  835.  
  836.  - Function: match-string COUNT &optional IN-STRING
  837.      This function returns, as a string, the text matched in the last
  838.      search or match operation.  It returns the entire text if COUNT is
  839.      zero, or just the portion corresponding to the COUNTth
  840.      parenthetical subexpression, if COUNT is positive.  If COUNT is
  841.      out of range, or if that subexpression didn't match anything, the
  842.      value is `nil'.
  843.  
  844.      If the last such operation was done against a string with
  845.      `string-match', then you should pass the same string as the
  846.      argument IN-STRING.  Otherwise, after a buffer search or match,
  847.      you should omit IN-STRING or pass `nil' for it; but you should
  848.      make sure that the current buffer when you call `match-string' is
  849.      the one in which you did the searching or matching.
  850.  
  851.  - Function: match-beginning COUNT
  852.      This function returns the position of the start of text matched by
  853.      the last regular expression searched for, or a subexpression of it.
  854.  
  855.      If COUNT is zero, then the value is the position of the start of
  856.      the entire match.  Otherwise, COUNT specifies a subexpression in
  857.      the regular expresion, and the value of the function is the
  858.      starting position of the match for that subexpression.
  859.  
  860.      The value is `nil' for a subexpression inside a `\|' alternative
  861.      that wasn't used in the match.
  862.  
  863.  - Function: match-end COUNT
  864.      This function is like `match-beginning' except that it returns the
  865.      position of the end of the match, rather than the position of the
  866.      beginning.
  867.  
  868.    Here is an example of using the match data, with a comment showing
  869. the positions within the text:
  870.  
  871.      (string-match "\\(qu\\)\\(ick\\)"
  872.                    "The quick fox jumped quickly.")
  873.                    ;0123456789
  874.           => 4
  875.      
  876.      (match-string 0 "The quick fox jumped quickly.")
  877.           => "quick"
  878.      (match-string 1 "The quick fox jumped quickly.")
  879.           => "qu"
  880.      (match-string 2 "The quick fox jumped quickly.")
  881.           => "ick"
  882.      
  883.      (match-beginning 1)       ; The beginning of the match
  884.           => 4                 ;   with `qu' is at index 4.
  885.      
  886.      (match-beginning 2)       ; The beginning of the match
  887.           => 6                 ;   with `ick' is at index 6.
  888.      
  889.      (match-end 1)             ; The end of the match
  890.           => 6                 ;   with `qu' is at index 6.
  891.      
  892.      (match-end 2)             ; The end of the match
  893.           => 9                 ;   with `ick' is at index 9.
  894.  
  895.    Here is another example.  Point is initially located at the beginning
  896. of the line.  Searching moves point to between the space and the word
  897. `in'.  The beginning of the entire match is at the 9th character of the
  898. buffer (`T'), and the beginning of the match for the first
  899. subexpression is at the 13th character (`c').
  900.  
  901.      (list
  902.        (re-search-forward "The \\(cat \\)")
  903.        (match-beginning 0)
  904.        (match-beginning 1))
  905.          => (9 9 13)
  906.      
  907.      ---------- Buffer: foo ----------
  908.      I read "The cat -!-in the hat comes back" twice.
  909.              ^   ^
  910.              9  13
  911.      ---------- Buffer: foo ----------
  912.  
  913. (In this case, the index returned is a buffer position; the first
  914. character of the buffer counts as 1.)
  915.  
  916. 
  917. File: lispref.info,  Node: Replacing Match,  Next: Entire Match Data,  Prev: Simple Match Data,  Up: Match Data
  918.  
  919. Replacing the Text That Matched
  920. -------------------------------
  921.  
  922.    This function replaces the text matched by the last search with
  923. REPLACEMENT.
  924.  
  925.  - Function: replace-match REPLACEMENT &optional FIXEDCASE LITERAL
  926.           STRING
  927.      This function replaces the text in the buffer (or in STRING) that
  928.      was matched by the last search.  It replaces that text with
  929.      REPLACEMENT.
  930.  
  931.      If you did the last search in a buffer, you should specify `nil'
  932.      for STRING.  Then `replace-match' does the replacement by editing
  933.      the buffer; it leaves point at the end of the replacement text,
  934.      and returns `t'.
  935.  
  936.      If you did the search in a string, pass the same string as STRING.
  937.      Then `replace-match' does the replacement by constructing and
  938.      returning a new string.
  939.  
  940.      If FIXEDCASE is non-`nil', then the case of the replacement text
  941.      is not changed; otherwise, the replacement text is converted to a
  942.      different case depending upon the capitalization of the text to be
  943.      replaced.  If the original text is all upper case, the replacement
  944.      text is converted to upper case.  If the first word of the
  945.      original text is capitalized, then the first word of the
  946.      replacement text is capitalized.  If the original text contains
  947.      just one word, and that word is a capital letter, `replace-match'
  948.      considers this a capitalized first word rather than all upper case.
  949.  
  950.      If `case-replace' is `nil', then case conversion is not done,
  951.      regardless of the value of FIXED-CASE.  *Note Searching and Case::.
  952.  
  953.      If LITERAL is non-`nil', then REPLACEMENT is inserted exactly as
  954.      it is, the only alterations being case changes as needed.  If it
  955.      is `nil' (the default), then the character `\' is treated
  956.      specially.  If a `\' appears in REPLACEMENT, then it must be part
  957.      of one of the following sequences:
  958.  
  959.     `\&'
  960.           `\&' stands for the entire text being replaced.
  961.  
  962.     `\N'
  963.           `\N', where N is a digit, stands for the text that matched
  964.           the Nth subexpression in the original regexp.  Subexpressions
  965.           are those expressions grouped inside `\(...\)'.
  966.  
  967.     `\\'
  968.           `\\' stands for a single `\' in the replacement text.
  969.  
  970. 
  971. File: lispref.info,  Node: Entire Match Data,  Next: Saving Match Data,  Prev: Replacing Match,  Up: Match Data
  972.  
  973. Accessing the Entire Match Data
  974. -------------------------------
  975.  
  976.    The functions `match-data' and `set-match-data' read or write the
  977. entire match data, all at once.
  978.  
  979.  - Function: match-data
  980.      This function returns a newly constructed list containing all the
  981.      information on what text the last search matched.  Element zero is
  982.      the position of the beginning of the match for the whole
  983.      expression; element one is the position of the end of the match
  984.      for the expression.  The next two elements are the positions of
  985.      the beginning and end of the match for the first subexpression,
  986.      and so on.  In general, element number 2N corresponds to
  987.      `(match-beginning N)'; and element number 2N + 1 corresponds to
  988.      `(match-end N)'.
  989.  
  990.      All the elements are markers or `nil' if matching was done on a
  991.      buffer, and all are integers or `nil' if matching was done on a
  992.      string with `string-match'.  (In Emacs 18 and earlier versions,
  993.      markers were used even for matching on a string, except in the case
  994.      of the integer 0.)
  995.  
  996.      As always, there must be no possibility of intervening searches
  997.      between the call to a search function and the call to `match-data'
  998.      that is intended to access the match data for that search.
  999.  
  1000.           (match-data)
  1001.                =>  (#<marker at 9 in foo>
  1002.                     #<marker at 17 in foo>
  1003.                     #<marker at 13 in foo>
  1004.                     #<marker at 17 in foo>)
  1005.  
  1006.  - Function: set-match-data MATCH-LIST
  1007.      This function sets the match data from the elements of MATCH-LIST,
  1008.      which should be a list that was the value of a previous call to
  1009.      `match-data'.
  1010.  
  1011.      If MATCH-LIST refers to a buffer that doesn't exist, you don't get
  1012.      an error; that sets the match data in a meaningless but harmless
  1013.      way.
  1014.  
  1015.      `store-match-data' is an alias for `set-match-data'.
  1016.  
  1017. 
  1018. File: lispref.info,  Node: Saving Match Data,  Prev: Entire Match Data,  Up: Match Data
  1019.  
  1020. Saving and Restoring the Match Data
  1021. -----------------------------------
  1022.  
  1023.    When you call a function that may do a search, you may need to save
  1024. and restore the match data around that call, if you want to preserve the
  1025. match data from an earlier search for later use.  Here is an example
  1026. that shows the problem that arises if you fail to save the match data:
  1027.  
  1028.      (re-search-forward "The \\(cat \\)")
  1029.           => 48
  1030.      (foo)                   ; Perhaps `foo' does
  1031.                              ;   more searching.
  1032.      (match-end 0)
  1033.           => 61              ; Unexpected result--not 48!
  1034.  
  1035.    You can save and restore the match data with `save-match-data':
  1036.  
  1037.  - Macro: save-match-data BODY...
  1038.      This special form executes BODY, saving and restoring the match
  1039.      data around it.
  1040.  
  1041.    You can use `set-match-data' together with `match-data' to imitate
  1042. the effect of the special form `save-match-data'.  This is useful for
  1043. writing code that can run in Emacs 18.  Here is how:
  1044.  
  1045.      (let ((data (match-data)))
  1046.        (unwind-protect
  1047.            ...   ; May change the original match data.
  1048.          (set-match-data data)))
  1049.  
  1050.    Emacs automatically saves and restores the match data when it runs
  1051. process filter functions (*note Filter Functions::.) and process
  1052. sentinels (*note Sentinels::.).
  1053.  
  1054. 
  1055. File: lispref.info,  Node: Searching and Case,  Next: Standard Regexps,  Prev: Match Data,  Up: Searching and Matching
  1056.  
  1057. Searching and Case
  1058. ==================
  1059.  
  1060.    By default, searches in Emacs ignore the case of the text they are
  1061. searching through; if you specify searching for `FOO', then `Foo' or
  1062. `foo' is also considered a match.  Regexps, and in particular character
  1063. sets, are included: thus, `[aB]' would match `a' or `A' or `b' or `B'.
  1064.  
  1065.    If you do not want this feature, set the variable `case-fold-search'
  1066. to `nil'.  Then all letters must match exactly, including case.  This
  1067. is a buffer-local variable; altering the variable affects only the
  1068. current buffer.  (*Note Intro to Buffer-Local::.)  Alternatively, you
  1069. may change the value of `default-case-fold-search', which is the
  1070. default value of `case-fold-search' for buffers that do not override it.
  1071.  
  1072.    Note that the user-level incremental search feature handles case
  1073. distinctions differently.  When given a lower case letter, it looks for
  1074. a match of either case, but when given an upper case letter, it looks
  1075. for an upper case letter only.  But this has nothing to do with the
  1076. searching functions Lisp functions use.
  1077.  
  1078.  - User Option: case-replace
  1079.      This variable determines whether the replacement functions should
  1080.      preserve case.  If the variable is `nil', that means to use the
  1081.      replacement text verbatim.  A non-`nil' value means to convert the
  1082.      case of the replacement text according to the text being replaced.
  1083.  
  1084.      The function `replace-match' is where this variable actually has
  1085.      its effect.  *Note Replacing Match::.
  1086.  
  1087.  - User Option: case-fold-search
  1088.      This buffer-local variable determines whether searches should
  1089.      ignore case.  If the variable is `nil' they do not ignore case;
  1090.      otherwise they do ignore case.
  1091.  
  1092.  - Variable: default-case-fold-search
  1093.      The value of this variable is the default value for
  1094.      `case-fold-search' in buffers that do not override it.  This is the
  1095.      same as `(default-value 'case-fold-search)'.
  1096.  
  1097. 
  1098. File: lispref.info,  Node: Standard Regexps,  Prev: Searching and Case,  Up: Searching and Matching
  1099.  
  1100. Standard Regular Expressions Used in Editing
  1101. ============================================
  1102.  
  1103.    This section describes some variables that hold regular expressions
  1104. used for certain purposes in editing:
  1105.  
  1106.  - Variable: page-delimiter
  1107.      This is the regexp describing line-beginnings that separate pages.
  1108.      The default value is `"^\014"' (i.e., `"^^L"' or `"^\C-l"'); this
  1109.      matches a line that starts with a formfeed character.
  1110.  
  1111.    The following two regular expressions should *not* assume the match
  1112. always starts at the beginning of a line; they should not use `^' to
  1113. anchor the match.  Most often, the paragraph commands do check for a
  1114. match only at the beginning of a line, which means that `^' would be
  1115. superfluous.  When there is a nonzero left margin, they accept matches
  1116. that start after the left margin.  In that case, a `^' would be
  1117. incorrect.  However, a `^' is harmless in modes where a left margin is
  1118. never used.
  1119.  
  1120.  - Variable: paragraph-separate
  1121.      This is the regular expression for recognizing the beginning of a
  1122.      line that separates paragraphs.  (If you change this, you may have
  1123.      to change `paragraph-start' also.)  The default value is
  1124.      `"[ \t\f]*$"', which matches a line that consists entirely of
  1125.      spaces, tabs, and form feeds (after its left margin).
  1126.  
  1127.  - Variable: paragraph-start
  1128.      This is the regular expression for recognizing the beginning of a
  1129.      line that starts *or* separates paragraphs.  The default value is
  1130.      `"[ \t\n\f]"', which matches a line starting with a space, tab,
  1131.      newline, or form feed (after its left margin).
  1132.  
  1133.  - Variable: sentence-end
  1134.      This is the regular expression describing the end of a sentence.
  1135.      (All paragraph boundaries also end sentences, regardless.)  The
  1136.      default value is:
  1137.  
  1138.           "[.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*"
  1139.  
  1140.      This means a period, question mark or exclamation mark, followed
  1141.      optionally by a closing parenthetical character, followed by tabs,
  1142.      spaces or new lines.
  1143.  
  1144.      For a detailed explanation of this regular expression, see *Note
  1145.      Regexp Example::.
  1146.  
  1147. 
  1148. File: lispref.info,  Node: Syntax Tables,  Next: Abbrevs,  Prev: Searching and Matching,  Up: Top
  1149.  
  1150. Syntax Tables
  1151. *************
  1152.  
  1153.    A "syntax table" specifies the syntactic textual function of each
  1154. character.  This information is used by the parsing commands, the
  1155. complex movement commands, and others to determine where words, symbols,
  1156. and other syntactic constructs begin and end.  The current syntax table
  1157. controls the meaning of the word motion functions (*note Word Motion::.)
  1158. and the list motion functions (*note List Motion::.) as well as the
  1159. functions in this chapter.
  1160.  
  1161. * Menu:
  1162.  
  1163. * Basics: Syntax Basics.     Basic concepts of syntax tables.
  1164. * Desc: Syntax Descriptors.  How characters are classified.
  1165. * Syntax Table Functions::   How to create, examine and alter syntax tables.
  1166. * Motion and Syntax::         Moving over characters with certain syntaxes.
  1167. * Parsing Expressions::      Parsing balanced expressions
  1168.                                 using the syntax table.
  1169. * Standard Syntax Tables::   Syntax tables used by various major modes.
  1170. * Syntax Table Internals::   How syntax table information is stored.
  1171.  
  1172.